﻿@{
    ViewBag.Title = "JobSet";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
<script src="../../Scripts/SerializeForm.js" type="text/javascript"></script>
<script type="text/javascript">
   var jobClass = "@ViewData["jobClass"]";
   var jobID="@ViewData["jobID"]";
    $(document).ready(function () {
        $("#jobClass").val(jobClass);
        $("#jobID").val(jobID);
        $("#checkAllWeek").bind('click', function () {
            if ($("#checkAllWeek").attr('checked') == true) {
                $.each($("#weekTb input[type='checkbox']"), function (i, n) {
                    $(n).attr("checked", "checked");
                });
            }
            else {
                $.each($("#weekTb input[type='checkbox']"), function (i, n) {
                    $(n).removeAttr("checked");
                });
            }
        });
        $("#checkAllMonth").bind('click', function () {
            if ($("#checkAllMonth").attr('checked') == true) {
                $.each($("#monthTb input[type='checkbox']"), function (i, n) {
                    $(n).attr("checked", "checked");
                });
            }
            else {
                $.each($("#monthTb input[type='checkbox']"), function (i, n) {
                    $(n).removeAttr("checked");
                });
            }
        });
        $("#ischeckEndTimeChk").bind('click', function () {
            if ($("#ischeckEndTimeChk").attr('checked') == true) {
                $('#endTime').datetimebox({
                    disabled: false
                }); 
            }
            else {
                $('#endTime').datetimebox({
                    disabled: true
                }); 
            }
        });
        $("#everyWeekRb").bind('click', function () {
            $("#checkAllWeek").removeAttr("disabled");
            $("#Monday").removeAttr("disabled");
            $("#Tuesday").removeAttr("disabled");
            $("#Wednesday").removeAttr("disabled");
            $("#Thursday").removeAttr("disabled");
            $("#Friday").removeAttr("disabled");
            $("#Saturday").removeAttr("disabled");
            $("#Sunday").removeAttr("disabled");
        });
        $("#everyDayRb").bind('click', function () {
            $("#checkAllWeek").attr("disabled", "disabled");
            $("#Monday").attr("disabled", "disabled");
            $("#Tuesday").attr("disabled", "disabled");
            $("#Wednesday").attr("disabled", "disabled");
            $("#Thursday").attr("disabled", "disabled");
            $("#Friday").attr("disabled", "disabled");
            $("#Saturday").attr("disabled", "disabled");
            $("#Sunday").attr("disabled", "disabled");
        });
        $('#beginTime').datetimebox({
            currentText:"今天",
            closeText:"关闭",
            okText:"确定"
        });
        $('#endTime').datetimebox({
            currentText: "今天",
            closeText: "关闭",
            okText: "确定",
            disabled:true
        });
        $('#TriggerTime').timespinner({ 
            showSeconds: true,
            value:"00:00:00"  
        });

    });
    function DoAdd() {
        if($("#jobName").val()==""){
            alert("请输入工作名！");
            return;
        }
        else{
            $.ajax({
                type: 'POST',
                url: "/Home/VJobName",
                data: {jobName:$("#jobName").val()},
                dataType: "json",
                success: function (msg) {
                    if(msg==0){
                        alert("该工作名已经正在运行，请重新输入其他工作名！")
                    }
                    else{
                           $.ajax({
                            type: 'POST',
                            url: "/Home/doAdd",
                            data: eval('(' + form2Json("SetForm") + ')'),
                            dataType: "json",
                            success: function (msg) {
                                if(msg==1){
                                    parent.window.ReloadDatagrid();
                                    alert("添加工作成功！！");
                                }
                                else{
                                    alert("添加工作失败！！");
                                }
                            }
                        });
                    }

                }
            });
        }
    }
</script>
<form id="SetForm" method="post">
<table>
<tr>
<td>
<table border="0" cellspacing="0" cellpadding="0">
    <tr><td align="center" colspan="2" >&nbsp;<input type="hidden" id="jobClass" name="jobClass" /><input type="hidden" id="jobID" name="jobID" /></td></tr>
    <tr>
        <td align="center" colspan="2" >&nbsp;&nbsp;&nbsp;&nbsp;起始时间：<input id="beginTime" type="text" value=" " name="beginTime" style="width:155px;"/></td>
    </tr>
    <tr><td align="center" colspan="2" >&nbsp;</td></tr>
    <tr>
        <td align="center" colspan="2"  ><input type="checkbox" id="ischeckEndTimeChk" name="ischeckEndTimeChk"/>&nbsp;结束时间：<input type="text" id="endTime" value=" " name="endTime" style="width:155px;"/>
           </td>
    </tr>
    <tr><td align="center" colspan="2" >&nbsp;</td></tr>
    <tr>
        <td align="center" style="line-height:35px;">
            <input type="radio" id="everyDayRb" name="everyDayOrWeekRb" checked="checked" value="天" /><label for="everyDayRb">每天</label>
        </td>
        <td align="center" style="line-height:35px;"><input type="radio" id="everyWeekRb" name="everyDayOrWeekRb" value="星期" /><label for="everyWeekRb">每个星期</label></td>
    </tr>
    <tr>
        <td align="center" style="line-height:35px;">月份：&nbsp;<input  id="checkAllMonth" name="checkAllMonth" type="checkbox"/><label for="checkAllMonth">全选</label></td>
        <td align="center" style="line-height:35px;">星期：&nbsp;<input  id="checkAllWeek" name="checkAllWeek" type="checkbox" disabled="disabled"/><label for="checkAllWeek">全选</label></td>
    </tr>
    <tr>
        <td style="line-height:35px;">
            <table id="monthTb">
                <tr>
                    <td>
                        <input type="checkbox" id="January" name="January"/><label for="January">一月份</label> &nbsp;
                        <input type="checkbox" id="February" name="February"/><label for="February">二月份</label> &nbsp;
                        <input type="checkbox" id="March" name="March"/><label for="March">三月份</label> 
                        
                    </td>
                </tr>
                <tr>
                    <td>
                        <input type="checkbox" id="April" name="April"/><label for="April">四月份</label> &nbsp;
                        <input type="checkbox" id="May" name="May"/><label for="May">五月份</label> &nbsp;
                        <input type="checkbox" id="June" name="June"/><label for="June">六月份</label> 
                    </td>
                </tr>
                <tr>
                    <td>
                         <input type="checkbox" id="July" name="July"/><label for="July">七月份</label> &nbsp;
                        <input type="checkbox" id="August" name="August"/><label for="August">八月份</label> &nbsp;
                        <input type="checkbox" id="September" name="September"/><label for="September">九月份</label> 
                        
                    </td>
                </tr>
                <tr>
                    <td>
                        <input type="checkbox" id="October" name="October"/><label for="October">十月份</label> &nbsp;
                        <input type="checkbox" id="November" name="November"/><label for="November">十一月</label> &nbsp;
                        <input type="checkbox" id="December" name="December"/><label for="December">十二月</label> 
                    </td>
                </tr>
            </table>
        </td>
        <td align="center" style="line-height:35px;">
            <table  border="0" frame="lhs" id="weekTb" >
             <tr>
                <td>
                    <input  id="Monday" name="Monday" type="checkbox" disabled="disabled"/><label for="Monday">星期一</label>&nbsp;
                    <input  id="Tuesday" name="Tuesday" type="checkbox" disabled="disabled"/><label for="Tuesday">星期二</label>&nbsp;
                </td>
             </tr>
             <tr>
                <td>
                    <input  id="Wednesday" name="Wednesday" type="checkbox" disabled="disabled"/><label for="Wednesday">星期三</label>&nbsp;
                    <input  id="Thursday" name="Thursday" type="checkbox" disabled="disabled"/><label for="Thursday">星期四</label>&nbsp;
                </td>
             </tr>
             <tr>
                <td>
                    <input  id="Friday" name="Friday" type="checkbox" disabled="disabled"/><label for="Friday">星期五</label>&nbsp;
                    <input  id="Saturday" name="Saturday" type="checkbox" disabled="disabled"/><label for="Saturday">星期六</label>&nbsp;
                </td>
             </tr>
             <tr>
                <td>
                    <input  id="Sunday" name="Sunday" type="checkbox" disabled="disabled"/><label for="Sunday">星期天</label>&nbsp;
                </td>
             </tr>
            </table>
        </td>
    </tr>
    <tr><td align="center" colspan="2" >&nbsp;</td></tr>
    <tr>
        <td align="center" colspan="2" >&nbsp;&nbsp;&nbsp;&nbsp;触发时间：<input id="TriggerTime" type="text" value=" " name="TriggerTime" /></td>
    </tr>
    <tr><td align="center" colspan="2" >&nbsp;</td></tr>
    <tr>
     <td align="center" colspan="2" style="line-height:35px;"><a id="add" href="javascript:DoAdd()" class="easyui-linkbutton" plain="true">添加工作</a>                </td>
    </tr>
</table>
</td>
<td>
    <table>
        <tr>
            <td>工作名：<input type="text" id="jobName" name="jobName" size="15"/></td>
            
        </tr>
        <tr>
            <td>
                工作简介：
            </td>
        </tr>
        <tr>
            <td>
                <textarea cols="7" id="InfoText" name="InfoText" style="width:200px;"></textarea>
            </td>
        </tr>
    </table>
</td>
</tr>
</table>
</form>